package com.hgc.ch01.base;

/**
 * Created by 01367627 on 2019/6/14.
 */
public class ThreadYieldTest {

    static class RunnableImpl implements Runnable {

        public void run() {
            for (int i = 0; i < 100; i++) {
                System.out.println(Thread.currentThread().getName() + " Thread is Running:" + i);
                Thread.yield();
            }

        }
    }

    public static void main(String[] args) {
        Thread james = new Thread(new RunnableImpl(), "james");
        james.setPriority(Thread.MIN_PRIORITY);
        Thread goddnes = new Thread(new RunnableImpl(), "goddnes");
        goddnes.setPriority(Thread.MAX_PRIORITY);
        james.start();
        goddnes.start();
    }
}
